<template>
  <div class="water-quality-container">

    <div class="popup-header">
      <h3>{{ stationInfo.segmentname || '手工断面详情' }}</h3>
    </div>

    <div class="body">

      <!-- 标签区域 -->
      <div class="tags-row">
        <van-tag type="success" size="medium" round>{{ stationInfo.controllevel }}</van-tag>
        <van-tag v-if="stationInfo.ismanual !== undefined && stationInfo.ismanual !== null"
          :type="stationInfo.ismanual === '1' ? 'success' : 'default'" size="medium" round>
          {{ stationInfo.ismanual === "1" ? '手工断面' : '自动站' }}
        </van-tag>
        <van-tag type="primary" size="medium" round>{{ stationInfo.rivername }}</van-tag>
      </div>

      <div class="base-info-box">
        <div class="base-info-title">
          <div class="header-title">水质状况</div>
          <div class="sample-time">{{ stationInfo.sampleTime }}</div>
        </div>
        <div class="base-info-grid">
          <div class="base-info-item">
            <span class="base-info-label">水质评价</span>
            <span class="base-info-value" :class="getQualityClass(overviewInfo.waterQuality)">{{
              overviewInfo.waterQuality }}</span>
          </div>
          <div class="base-info-item">
            <span class="base-info-label">水质指数</span>
            <span class="base-info-value">{{ overviewInfo.segmentIndex }}</span>
          </div>
          <div class="base-info-item">
            <span class="base-info-label">当前水质级别</span>
            <span class="base-info-value">{{ overviewInfo.qualitylevelname }}</span>
          </div>
          <div class="base-info-item">
            <span class="base-info-label">目标水质级别</span>
            <span class="base-info-value">{{ overviewInfo.targetLevelName }}</span>
          </div>
        </div>
      </div>

      <div class="base-info-box">
        <div class="base-info-title">
          <div class="header-title">监测指标</div>
        </div>
        <div class="indicators-container">
          <div v-for="(indicator, index) in validIndicators" :key="indicator.id || index" class="indicator-card">
            <div class="indicator-header">
              <span class="indicator-name">{{ indicator.name }}</span>
            </div>
            <div class="indicator-content">
              <span class="indicator-value">{{ indicator.value }}</span>
            </div>
          </div>
        </div>

        <!-- 超标提示 -->
        <van-notice-bar v-if="exceedAlertTitle" class="exceed-alert" color="#ffffff" background="#ee0a24"
          left-icon="warning-o">
          <div class="exceed-alert-content">
            <span class="exceed-title">超标因子：</span>
            <span class="exceed-items">{{ exceedAlertTitle }}</span>
          </div>
        </van-notice-bar>
      </div>

      <!-- 水质状况区域 -->
      <div class="base-info-box">
        <div class="base-info-title">
          <div class="header-title">水质趋势分析</div>
        </div>
        <!-- 图表控制区域 -->
        <div class="chart-controls">
          <!-- <div class="control-header">
          <h3>水质趋势分析</h3>
        </div> -->
          <div class="period-control">
            <van-radio-group v-model="timePeriod" direction="horizontal" @change="handlePeriodChange"
              class="period-radio-group">
              <van-radio name="month" checked-color="#1890ff">月</van-radio>
              <van-radio name="year" checked-color="#1890ff">年</van-radio>
            </van-radio-group>
          </div>
        </div>

        <!-- 图表容器 -->
        <div class="chart-container">
          <div class="chart-wrapper">
            <div ref="chartRef" class="echart-container"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onBeforeUnmount, computed, watch } from 'vue'
import * as echarts from 'echarts'
import { getinfo, getAutoStationInfo, getManuaStationMonthTrend, getManuaStationYearTrend } from '@/api/shougongduanmian'
import StringUtils from '@/utils/string_utils'

// Props
const props = defineProps({
  featureId: {
    type: String,
    default: ''
  }
})


// Data
const stationInfo = ref({})
const overviewInfo = ref({})
const exceedAlertTitle = ref('')
const timePeriod = ref('month')
const dateRange = ref([])
const yearRangeStart = ref(null)
const yearRangeEnd = ref(null)
const indicators = ref([])
const targetQuality = ref(2)
const times = ref([
  "2025-08-10 00:00",
  "2025-08-10 01:00",
  "2025-08-10 02:00",
  "2025-08-10 03:00",
  "2025-08-10 04:00",
  "2025-08-10 05:00",
  "2025-08-10 06:00",
  "2025-08-10 07:00",
  "2025-08-10 08:00",
  "2025-08-10 09:00",
  "2025-08-10 10:00"
])
const qualityData = ref([2, 2, 2, 2, 2, 0, 2, 3, 3, 3, 3])
const monitoringData = ref({})
const chart = ref(null)

// Refs
const chartRef = ref(null)

// Computed
const validIndicators = computed(() => {
  return indicators.value.filter(indicator =>
    indicator.value !== undefined &&
    indicator.value !== null &&
    indicator.value !== ''
  ).map(indicator => ({
    ...indicator,
    value: StringUtils.parseFloat(indicator.value)
  }))
})


const levelMap = {
  "劣Ⅴ类": 6,
  "Ⅴ类": 5,
  "Ⅳ类": 4,
  "Ⅲ类": 3,
  "Ⅱ类": 2,
  "Ⅰ类": 1,
  "无类别": 0
}



// Methods
// 计算水质等级对应的颜色类
const getQualityClass = computed(() => (quality) => {
  if (!quality) return '';
  return `quality-${quality.replace(/\s+/g, '-')}`;
});
const formatMonth = (date) => {
  if (!date) return ''
  const year = date.getFullYear()
  const month = String(date.getMonth() + 1).padStart(2, '0')
  return `${year}-${month}`
}

const formatYear = (date) => {
  if (!date) return ''
  const year = date.getFullYear()
  return `${year}`
}

const initDateRange = () => {
  let end = new Date()
  let start = new Date()
  start.setMinutes(0, 0, 0)

  switch (timePeriod.value) {
    case 'month':
      end.setDate(1)
      end.setHours(0, 0, 0, 0)
      start.setMonth(start.getMonth() - 12)
      dateRange.value = [start, end]
      break
    case 'year':
      start.setFullYear(start.getFullYear() - 10)
      yearRangeStart.value = start
      yearRangeEnd.value = end
      break
  }
}

const getbaseinfo = () => {
  getinfo({ id: props.featureId }).then(res => {
    // console.log("stationInfo", res.data)
    stationInfo.value = res.data
    if (res.data.targetlevelname && levelMap[res.data.targetlevelname] !== undefined) {
      targetQuality.value = levelMap[res.data.targetlevelname]
    } else {
      targetQuality.value = 2 // 默认为Ⅱ类
    }
  }).catch(error => {
    console.error('获取基础信息失败:', error)
  })
}

const getStationInfo = () => {
  getAutoStationInfo({ id: props.featureId }).then(res => {
    // console.log("overviewInfo", res.data)
    overviewInfo.value = res.data
    indicators.value = res.data.itemDataList
    const overstandardList = res.data.overstandardList
    exceedAlertTitle.value = overstandardList.map(item => `${item.name}(${item.value})`).join(',')
    // exceedAlertTitle.value = "测试"
  }).catch(error => {
    console.error('获取站点信息失败:', error)
  })
}

const getMonitoringData = () => {
  let apiFunction
  let startTime
  let endTime

  if (timePeriod.value === 'year') {
    apiFunction = getManuaStationYearTrend
    startTime = formatYear(yearRangeStart.value)
    endTime = formatYear(yearRangeEnd.value)
  } else if (timePeriod.value === 'month') {
    apiFunction = getManuaStationMonthTrend
    startTime = formatMonth(dateRange.value[0])
    endTime = formatMonth(dateRange.value[1])
  } else {
    console.warn('未知的时间段类型:', timePeriod.value)
    return
  }

  apiFunction({
    id: props.featureId,
    startTime: startTime,
    endTime: endTime
  }).then(res => {
    monitoringData.value = convertData(res.data)
    times.value = monitoringData.value.dateList
    qualityData.value = monitoringData.value.value
    // console.log("monitoringData.value", monitoringData.value)
    renderChart()
  }).catch(error => {
    console.error('获取监测数据失败:', error)
  })

}

const convertData = (data) => {
  const value = data.level.map(level => levelMap[level])
  return {
    value,
    ...data
  }
}

const handlePeriodChange = () => {
  initDateRange()
  getMonitoringData()
}

// const handleQuery = () => {
//   if (timePeriod.value === 'month') {
//     if (!dateRange.value || dateRange.value.length !== 2) {
//       // 这里可以使用 vant 的 Toast 提示
//       return
//     }

//     if (dateRange.value[0] > dateRange.value[1]) {
//       // 这里可以使用 vant 的 Toast 提示
//       return
//     }
//   }

//   if (timePeriod.value === 'year') {
//     if (!yearRangeEnd.value || !yearRangeStart.value) {
//       // 这里可以使用 vant 的 Toast 提示
//       return
//     }

//     if (yearRangeStart.value > yearRangeEnd.value) {
//       // 这里可以使用 vant 的 Toast 提示
//       return
//     }
//   }

//   getMonitoringData()
// }

const getOption = () => {
  const option = {
    title: {
      show: false,
      text: '水质趋势图',
      left: 'center',
      textStyle: {
        fontSize: 16,
        fontWeight: 'bold'
      },
      padding: [0, 0, 20, 0]
    },
    tooltip: {
      trigger: 'axis',
      backgroundColor: 'rgba(255, 255, 255, 0.9)',
      borderColor: '#ddd',
      borderWidth: 1,
      textStyle: {
        color: '#333'
      },
      formatter: function (params, ticket, callback) {
        // 可选：如果需要在y轴上显示水质等级名称而不是数字
        console.log('params', params);
        const param = params[0];
        const levelNames = ['无类别', 'Ⅰ类', 'Ⅱ类', 'Ⅲ类', 'Ⅳ类', 'Ⅴ类', '劣Ⅴ类'];
        return param.name + '：' + levelNames[param.value] || param.value;
      },
    },
    legend: {
      show: false,
      top: 'bottom',
      left: 'center'
    },
    grid: {
      left: '3%',
      right: '7%',
      bottom: '3%',
      top: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: times.value,
      // name: '监测时间',
      // nameLocation: 'middle',
      // nameGap: 30
    },
    yAxis: [
      {
        type: 'value',
        // name: '水质',
        // nameLocation: 'middle',
        // nameGap: 50,
        min: 0,
        max: 6,
        interval: 1,
        splitLine: {
          lineStyle: {
            color: 'rgba(0, 0, 0, 0.05)'
          }
        },
        axisLabel: {
          formatter: function (value) {
            // 可选：如果需要在y轴上显示水质等级名称而不是数字
            const levelNames = ['无类别', 'Ⅰ类', 'Ⅱ类', 'Ⅲ类', 'Ⅳ类', 'Ⅴ类', '劣Ⅴ类'];
            return levelNames[value] || value;
          }
        }
      }
    ],
    series: [
      {
        name: '水质',
        type: 'line',
        data: qualityData.value,
        symbol: 'circle',
        symbolSize: 6,
        emphasis: {
          symbolSize: 8
        },
        lineStyle: {
          width: 3,
          color: '#4bc0c0'
        },
        itemStyle: {
          color: '#4bc0c0'
        },
        smooth: true,
        markLine: {
          data: [
            {
              type: 'value',
              name: '目标水质',
              yAxis: targetQuality.value,
              lineStyle: {
                color: '#dc3545',
                type: 'dashed',
                width: 2
              },
              label: {
                show: true,
                position: 'insideMiddleTop',
                color: '#dc3545',
                fontSize: 10,
                formatter: function (params) {
                  const levelNames = ['无类别', 'Ⅰ类', 'Ⅱ类', 'Ⅲ类', 'Ⅳ类', 'Ⅴ类', '劣Ⅴ类'];
                  return params.name + '：' + levelNames[params.value] || params.value;
                }
              }
            }
          ]
        }
      }
    ],
    dataZoom: [
      {
        type: 'inside',
        xAxisIndex: 0,
        start: 0,
        end: 100
      },
      {
        show: true,
        type: 'slider',
        xAxisIndex: 0,
        start: 0,
        end: 100,
        bottom: 50
      }
    ],
    animation: true,
    animationDuration: 1000,
    animationEasing: 'cubicOut'
  }

  return option
}

const renderChart = () => {
  // 确保 DOM 元素存在
  if (!chartRef.value) {
    console.warn('图表容器未找到')
    return
  }

  // 如果图表已存在，先销毁
  if (chart.value) {
    chart.value.dispose()
  }

  // 初始化图表
  chart.value = echarts.init(chartRef.value)
  const option = getOption()
  chart.value.setOption(option, true)
}

const handleResize = () => {
  if (chart.value) {
    chart.value.resize()
  }
}

// Calendar events
// const onMonthConfirm = (values) => {
//   dateRange.value = values
//   showMonthPicker.value = false
// }

// const onYearStartConfirm = ({ selectedValues }) => {
//   yearRangeStart.value = selectedValues[0]
//   showYearStartPicker.value = false
// }

// const onYearEndConfirm = ({ selectedValues }) => {
//   yearRangeEnd.value = selectedValues[0]
//   showYearEndPicker.value = false
// }

// Watch
watch(() => props.featureId, (newVal, oldVal) => {
  if (newVal) {
    if (oldVal !== "" && newVal != oldVal) {
      console.log('featureId', newVal)
      initDateRange()
      getbaseinfo()
      getStationInfo()
      getMonitoringData()
    }
  }
}, { immediate: true })
// Lifecycle
onMounted(() => {
  initDateRange()
  getbaseinfo()
  getStationInfo()
  getMonitoringData()
})

onBeforeUnmount(() => {
  if (chart.value) {
    chart.value.dispose()
  }
  window.removeEventListener('resize', handleResize)
})
</script>

<style scoped>
/* 主要容器样式 */
.water-quality-container {
  max-width: 100%;
  width: 100%;
  margin: 0;
  border-radius: 0;
  padding: 0;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 设置容器高度为视口高度 */
  height: 80vh;
  /* 确保在不同设备上正常显示 */
  position: fixed;
}

/* 触摸滚动通用样式 */
.touch-scroll {
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* 隐藏滚动条但保持功能 */
.touch-scroll::-webkit-scrollbar {
  display: none;
}

/* 弹窗头部样式 */
.popup-header {
  font-size: 18px;
  font-weight: 600;
  padding: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 内容区域样式 */
.body {
  padding: 15px;
  /* 启用垂直滚动 */
  overflow-y: auto;
  /* 占满剩余空间 */
  flex: 1;
  /* 优化iOS滚动体验 */
  -webkit-overflow-scrolling: touch;
  /* 隐藏滚动条 */
  -ms-overflow-style: none;
  scrollbar-width: none;
}


/* 隐藏滚动条但保持功能 */
.body::-webkit-scrollbar {
  display: none;
}

/* 标签行样式 */
.tags-row {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 基础信息卡片样式 */
.base-info-box {
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  border: 1px solid #f0f0f0;
  transition: all 0.3s ease;
}

.base-info-box:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

/* 标题区域样式 */
.base-info-title {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
  margin-bottom: 12px;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
}

.sample-time {
  font-size: 14px;
  color: #7f8c8d;
  background: #ecf0f1;
  padding: 4px 12px;
  border-radius: 20px;
}

/* 信息网格布局 */
.base-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

/* 信息项样式 */
.base-info-item {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.base-info-item:hover {
  background: linear-gradient(135deg, #f0f2f5, #dde1e6);
}

/* 标签和值的样式 */
.base-info-label {
  font-weight: 500;
  color: #7f8c8d;
  font-size: 12px;
}

.base-info-value {
  margin-top: 4px;
  font-weight: 700;
  color: #2c3e50;
  font-size: 14px;
  border-radius: 20px;
}

/* 水质级别特殊样式 */
.base-info-value.quality-level {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

/* 水质分类颜色样式 */
.quality-Ⅰ类 {
  background: linear-gradient(135deg, #52c41a, #389e0d);
  color: white;
}

.quality-Ⅱ类 {
  background: linear-gradient(135deg, #1890ff, #096dd9);
  color: white;
}

.quality-Ⅲ类 {
  background: linear-gradient(135deg, #13c2c2, #08979c);
  color: white;
}

.quality-Ⅳ类 {
  background: linear-gradient(135deg, #faad14, #d48806);
  color: white;
}

.quality-Ⅴ类 {
  background: linear-gradient(135deg, #fa8c16, #d46b08);
  color: white;
}

.quality-劣Ⅴ类 {
  background: linear-gradient(135deg, #f5222d, #cf1322);
  color: white;
}

/* 监测指标容器 */
.indicators-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

/* 指标卡片样式 */
.indicator-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12rpx;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid #eee;
}

.indicator-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.indicator-name {
  font-weight: 500;
  color: #7f8c8d;
  font-size: 13px;
  margin-bottom: 8px;
}

.indicator-value {
  font-weight: 700;
  font-size: 18px;
  color: #2c3e50;
}

/* 图表控制区域 */
.chart-controls {
  margin: 12px 0;
}

.period-radio-group {
  background: #f8f9fa;
  padding: 10px 15px;
  border-radius: 12px;
}

/* 图表容器 */

.chart-wrapper {
  background: #fafafa;
  border-radius: 10px;
  padding: 10px;
}

.echart-container {
  width: 100%;
  height: 350px;
}

/* 超标提示 */
.exceed-alert {
  border-radius: 10px;
  border: none;
  padding: 12px 15px;
}

.exceed-alert-content {
  display: flex;
  align-items: center;
}

.exceed-title {
  font-weight: bold;
  margin-right: 8px;
}

/* 移动端响应式设计 */
@media (max-width: 768px) {

  /* 进一步优化移动设备上的滚动体验 */
  .body {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }


  .base-info-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .base-info-box {
    padding: 15px;
  }

  .base-info-title {
    flex-direction: row;
    gap: 8px;
  }

  .sample-time {
    font-size: 12px;
    padding: 3px 10px;
  }

  .header-title {
    font-size: 16px;
  }

  .indicators-container {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }

  .indicator-value {
    font-size: 16px;
  }

  .echart-container {
    height: 300px;
  }

  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }
}

/* 为触摸设备添加特殊样式 */
@media (hover: none) and (pointer: coarse) {

  /* 优化滚动效果 */
  .body {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}
</style>
<!-- <style scoped>
.water-quality-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px;
  background-color: #f9fafb;
}

.tags-row {
  margin-bottom: 15px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-weight: bold;
}

.evaluation-descriptions {
  margin-bottom: 20px;
  background-color: #f8fafc;
  padding: 10px;
}

.deep-color {
  color: #333 !important;
  font-weight: 500;
}

.indicators-title {
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
}

.indicators-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.indicator-item {
  border-radius: 6px;
  padding: 5px;
  background-color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid #eee;
}

.indicator-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.indicator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.indicator-name {
  font-weight: 500;
  color: #333;
  font-size: 14px;
}

.indicator-main {
  margin-bottom: 8px;
}

.indicator-value {
  font-weight: bold;
  font-size: 18px;
  color: #333;
  margin-right: 5px;
}

.chart-controls {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.period-control {
  width: 100%;
}

.time-range-control {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.query-btn {
  white-space: nowrap;
}

.echart-container {
  width: 100%;
  height: 300px;
}

.year-range-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-separator {
  margin: 0 5px;
}

.exceed-alert-content {
  display: flex;
  align-items: center;
}

.exceed-title {
  font-weight: bold;
}

.water-quality-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
  min-height: 100vh;
}

.tags-row {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.water-quality-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
}

.sample-time {
  font-size: 14px;
  color: #7f8c8d;
  background: #ecf0f1;
  padding: 4px 12px;
  border-radius: 20px;
}

.evaluation-descriptions {
  margin: 20px 0;
  padding: 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.evaluation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.evaluation-item:last-child {
  margin-bottom: 0;
}

.evaluation-label {
  color: #7f8c8d;
  font-weight: 500;
  font-size: 14px;
}

.water-quality-value {
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
}

.quality-Ⅰ类 {
  background: linear-gradient(135deg, #52c41a, #389e0d);
  color: white;
}

.quality-Ⅱ类 {
  background: linear-gradient(135deg, #1890ff, #096dd9);
  color: white;
}

.quality-Ⅲ类 {
  background: linear-gradient(135deg, #13c2c2, #08979c);
  color: white;
}

.quality-Ⅳ类 {
  background: linear-gradient(135deg, #faad14, #d48806);
  color: white;
}

.quality-Ⅴ类 {
  background: linear-gradient(135deg, #fa8c16, #d46b08);
  color: white;
}

.quality-劣Ⅴ类 {
  background: linear-gradient(135deg, #f5222d, #cf1322);
  color: white;
}

.segment-index-value {
  font-weight: 700;
  color: #1890ff;
  font-size: 16px;
}

.section-header {
  margin: 25px 0 15px;
}

.section-header h3 {
  color: #2c3e50;
  font-weight: 600;
  margin-bottom: 15px;
  position: relative;
  padding-bottom: 8px;
}

.section-header h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 3px;
  background: linear-gradient(to right, #1890ff, #52c41a);
  border-radius: 3px;
}

.indicators-title {
  font-weight: 600;
  color: #2c3e50;
  font-size: 16px;
}

.indicators-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.indicator-card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 12px;
  padding: 15px 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid #eee;
}

.indicator-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.indicator-name {
  font-weight: 500;
  color: #7f8c8d;
  font-size: 13px;
  margin-bottom: 8px;
}

.indicator-value {
  font-weight: 700;
  font-size: 18px;
  color: #2c3e50;
}

.chart-controls {
  margin: 25px 0;
}

.control-header h3 {
  color: #2c3e50;
  font-weight: 600;
  margin-bottom: 15px;
}

.period-radio-group {
  background: #f8f9fa;
  padding: 10px 15px;
  border-radius: 12px;
}

.chart-container {
  background: white;
  border-radius: 16px;
  padding: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.chart-wrapper {
  background: #fafafa;
  border-radius: 10px;
  padding: 10px;
}

.echart-container {
  width: 100%;
  height: 350px;
}

.exceed-alert {
  border-radius: 10px;
  margin: 20px 0;
  border: none;
  padding: 12px 15px;
}

.exceed-alert-content {
  display: flex;
  align-items: center;
}

.exceed-title {
  font-weight: bold;
  margin-right: 8px;
}

.elevated-card {
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.elevated-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.glass-morphism {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

@media (max-width: 768px) {
  .water-quality-container {
    padding: 10px;
  }
  
  .indicators-container {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }
  
  .indicator-card {
    padding: 12px 8px;
  }
  
  .indicator-value {
    font-size: 16px;
  }
  
  .echart-container {
    height: 300px;
  }
  
  .sample-time {
    font-size: 12px;
    padding: 3px 10px;
  }
}
@media (max-width: 768px) {
  .water-quality-container {
    padding: 10px;
  }

  .chart-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .time-range-control {
    width: 100%;
  }

  .echart-container {
    height: 300px;
  }

  .indicators-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .indicator-item {
    padding: 12px;
  }

  .indicator-value {
    font-size: 16px;
  }
}
</style> -->